Skip to content

fix(usage): handle missing Token Plan quota fields - #141

Merged
gujieye merged 6 commits into
modelstudioai:mainfrom
sonicg83:codex/usage-token-plan-reset-times
Aug 14, 2026
Merged

fix(usage): handle missing Token Plan quota fields#141
gujieye merged 6 commits into
modelstudioai:mainfrom
sonicg83:codex/usage-token-plan-reset-times

Conversation

@sonicg83

@sonicg83 sonicg83 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add usage token-plan JSON and human-readable usage views
  • tolerate omitted reset timestamps when the corresponding quota percentage is zero
  • treat missing quota percentage fields as a possibly unlimited quota window

User-visible behavior

When a quota field is unavailable, the view reports that the relevant 5-hour or 1-week limit may be unlimited and directs users to verify it in the Bailian Token Plan console. A completely empty service response is valid and produces an empty JSON object with the same view guidance.

Root cause

The Token Plan usage service can omit reset timestamps for unused quota windows and can omit the quota fields entirely when a limit is configured as unlimited. The command previously treated these fields as required numeric values.

Validation

  • pnpm --filter bailian-cli-commands exec vp check
  • pnpm --filter bailian-cli-commands exec vp test tests/token-plan-usage.test.ts tests/e2e/usage-token-plan.e2e.test.ts

@sonicg83
sonicg83 marked this pull request as ready for review August 6, 2026 01:20
@sonicg83 sonicg83 changed the title fix(usage): handle missing Token Plan reset times fix(usage): handle missing Token Plan quota fields Aug 6, 2026
@gujieye

gujieye commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Hi @sonicg83, thank you for the contribution! The Token Plan usage view is a great addition, and the handling of omitted quota fields is well thought out. 🙏

I've pushed a follow-up commit (39a4881) on top of your branch to align it with a few repo conventions before merging. To summarize the changes:

Output format

  • Replaced the mutually exclusive --json / --view flags with the repo-wide --output convention used by the other usage commands: the human-readable view is now the default, and --output json emits the four core fields. --dry-run also respects the selected format now.

Response parsing

  • Relaxed readUsage to tolerant reading: each quota field is read independently, and any missing or non-numeric value is simply treated as absent (possibly unlimited) instead of throwing an "unexpected format" error. This matches our convention of not second-guessing well-formed 200 responses, and makes the "missing percentage → possibly unlimited" behavior unconditional.

Polish

  • Translated the hardcoded Chinese "may be unlimited" messages to English to match the rest of the CLI output.
  • Moved formatDateTime into shared.ts next to formatDate, introduced a QuotaWindow type, and simplified the line/progress-bar styling helpers.

Docs & tests

  • Added the bl usage token-plan entry to the bailian-cli SKILL.md routing table and regenerated the reference docs.
  • Restructured the e2e file to follow the two-block describe convention, and expanded the unit tests (7 → 12) to cover the JSON path with real data and the newly tolerated edge cases.

All checks pass (vp check clean, 12/12 unit tests, 5/5 e2e including real Console calls). Please take a look and let me know if anything doesn't match your intent — happy to adjust. Thanks again!

@gujieye
gujieye merged commit b402f3e into modelstudioai:main Aug 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants